home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / URI-1.19 / t / http.t < prev    next >
Encoding:
Text File  |  2001-09-01  |  1.4 KB  |  56 lines

  1. print "1..13\n";
  2.  
  3. use URI;
  4.  
  5. $u = URI->new("<http://www.perl.com/path?q=f⌠o>");
  6.  
  7. #print "$u\n";
  8. print "not " unless $u eq "http://www.perl.com/path?q=f%F4o";
  9. print "ok 1\n";
  10.  
  11. print "not " unless $u->port == 80;
  12. print "ok 2\n";
  13.  
  14. # play with port
  15. $old = $u->port(8080);
  16. print "not " unless $old == 80 && $u eq "http://www.perl.com:8080/path?q=f%F4o";
  17. print "ok 3\n";
  18.  
  19. $u->port(80);
  20. print "not " unless $u eq "http://www.perl.com:80/path?q=f%F4o";
  21. print "ok 4\n";
  22.  
  23. $u->port("");
  24. print "not " unless $u eq "http://www.perl.com:/path?q=f%F4o" && $u->port == 80;
  25. print "ok 5\n";
  26.  
  27. $u->port(undef);
  28. print "not " unless $u eq "http://www.perl.com/path?q=f%F4o";
  29. print "ok 6\n";
  30.  
  31. @q = $u->query_form;
  32. print "not " unless @q == 2 && "@q" eq "q f⌠o";
  33. print "ok 7\n";
  34.  
  35. $u->query_form(foo => "bar", bar => "baz");
  36. print "not " unless $u->query eq "foo=bar&bar=baz";
  37. print "ok 8\n";
  38.  
  39. print "not " unless $u->host eq "www.perl.com";
  40. print "ok 9\n";
  41.  
  42. print "not " unless $u->path eq "/path";
  43. print "ok 10\n";
  44.  
  45. $u->scheme("https");
  46. print "not " unless $u->port == 443;
  47. print "ok 11\n";
  48.  
  49. print "not " unless $u eq "https://www.perl.com/path?foo=bar&bar=baz";
  50. print "ok 12\n";
  51.  
  52. $u = URI->new("http://%77%77%77%2e%70%65%72%6c%2e%63%6f%6d/%70%75%62/%61/%32%30%30%31/%30%38/%32%37/%62%6a%6f%72%6e%73%74%61%64%2e%68%74%6d%6c");
  53. print "not " unless $u->canonical eq "http://www.perl.com/pub/a/2001/08/27/bjornstad.html";
  54. print "ok 13\n";
  55.  
  56.